/**
 * @param {string} s
 * @return {boolean}
 */
 var isValid = function(s) {
    const map={
        "{":"}",
        "[":"]",
        "(":")"
    }
    let arr=[];
    let n=0,m=s.length;
    for(;n<m;n++){
        if(n>0 && map[arr[arr.length-1]]==s[n]){
            arr.pop();
        }
        else{
            arr.push(s[n]);
        }
        console.log(arr,n);      
    }
    if(arr.length>0){
        return false;
    }
    return true;
};
let s = "()"
console.log(isValid(s));